#ifndef QUERYWIDGET_H
#define QUERYWIDGET_H

#include "common/baseeditor.h"
#include "m_fhs.h"

namespace Ui {
class QueryWidget;
}

class QueryWidget : public BaseEditor
{
    Q_OBJECT

public:
    explicit QueryWidget(QWidget *parent,
                         const QSqlDatabase &db_);
    ~QueryWidget();

    void prepareStatement(const QMap<QString, QString> &map);
    void generateMenu();
    void updateView();
    void setHeaderData();

    void query(const QString &sql);
    void queryByCode();
    void queryByName();

signals:
    void showMessage(const QString &message);
    void transferLog(const QString &log);

protected:
    void keyPressEvent(QKeyEvent *event);

private slots:
    void on_tableView_doubleClicked(const QModelIndex &index);

private:
    Ui::QueryWidget *ui;

    QSqlQueryModel *queryModel;
    QSqlDatabase db;
    QMap<QString,QString> statementMap;
};

#endif // QUERYWIDGET_H
